package com.niit.musicserver.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.niit.musicserver.entity.domain.Songlist;
import com.niit.musicserver.mapper.SonglistMapper;
import com.niit.musicserver.service.SonglistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Author: cheng_jianzhen
 * @CreateTime： 2024/1/15 11:01
 */
@Service
public class SonglistServiceImpl implements SonglistService {

    @Autowired
    private SonglistMapper songlistMapper;

    /**
     * @Description: 根据歌单查询条件查询歌单列表
     * @Author: cheng_jianzhen
     * @CreateTime: 2024/1/15 11:01
     * @param: songlist
     * @return: java.util.List<com.niit.musicserver.entity.domain.Songlist>
     **/
    @Override
    public List<Songlist> getListBySonglist(Songlist songlist){
//        开启分页，将页码，每页纪录数
        PageHelper.startPage(songlist.getPageNum(), songlist.getPageSize());
        List<Songlist> songlists = songlistMapper.selectListBySonglist(songlist);
        return songlists;
    }

    /**
     * @param :id
     * @Description: 根据id获取歌单详细信息
     * @Author: cheng_jianzhen
     * @CreateTime: 2024/1/17 9:24
     * @param: songlistId
     * @return: com.niit.musicserver.entity.domain.Songlist
     */
    @Override
    public Songlist getById(Integer id) {

        return songlistMapper.selectById(id);
    }

    /**
     * @Description: 根据id更新歌单信息
     * @Author: cheng_jianzhen
     * @CreateTime: 2024/1/17 10:19
     * @param: songlist
     * @return: int
     */
    @Override
    public int updateById(Songlist songlist) {
        return songlistMapper.updateById(songlist);
    }

    /**
     * @Description: 新增歌单
     * @Author: cheng_jianzhen
     * @CreateTime: 2024/1/17 11:04
     * @param: songlist
     * @return: int
     **/
    @Override
    public int saveSonglist(Songlist songlist) {
        return songlistMapper.insertSonglist(songlist);
    }


    /**
     * @Description: 根据id删除歌单
     * @Author: cheng_jianzhen
     * @CreateTime: 2024/1/18 8:44
     * @param: songlistId
     * @return: int
     **/
    @Override
    public int deteteById(Integer id) {
//        逻辑删除（一般使用）
        return songlistMapper.deleteById(id);
    }


}
